class Solution {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int count = duration;
        for (int i = 0; i < timeSeries.length - 1; i++) {
            if (timeSeries[i + 1] >= timeSeries[i] + duration) {
                count += duration;
            } else {
                count += timeSeries[i + 1] - timeSeries[i];
            }
        }
        return count;
    }
}